-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements for Relocatable Compilations #2978
Conversation
Thanks for the contribution. This should be marked WIP until #2977 is merged. |
07bf128
to
4339001
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's WIP, but figured I'd comment anyway
(uint8_t *)TR::SymbolType::typeClass, | ||
TR_SymbolFromManager, | ||
cg()), __FILE__, __LINE__, getNode()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should assert here if !cg()->comp()->getOption(TR_UseSymbolValidationManager)
? Otherwise, don't we know we're not relocating a class pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good idea; although before this code, we never created a DataSnippet for a class pointer under AOT - this code is now active under AOT because checkcast inlining was enabled.
if (comp()->compileRelocatableCode() && !comp()->getOption(TR_DisablePeekAOTResolutions)) | ||
if (comp()->compileRelocatableCode() && | ||
!comp()->getOption(TR_UseSymbolValidationManager) && | ||
!comp()->getOption(TR_DisablePeekAOTResolutions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a more detailed commit message to cover these changes.
compiler/compile/VirtualGuard.cpp
Outdated
@@ -196,8 +196,6 @@ TR_VirtualGuard::createVftGuard | |||
aconstNode->setInlinedSiteIndex(calleeIndex); | |||
aconstNode->setByteCodeIndex(0); | |||
|
|||
comp->verifySymbolHasBeenValidated(static_cast<void *>(thisClass)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to squash this change with the one in #2977 that introduced the function in the first place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you're right, I was trying to avoid merge conflicts :) . I'll try and clean this up.
4339001
to
c1e9686
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the primary things that need to be fixed now are to clean up the commit titles/messages and I would like to hear the argument around methods being relocated using the old mechanisms even though classes are in the new mechanism.
compiler/compile/OMRCompilation.hpp
Outdated
* a data structure, looking at several different possible answers | ||
* before finally deciding on one. For a relocatable compile, only | ||
* the final answer is important. Thus, a heuristic region is used to | ||
* ignore all of the intermediate steps in determining the final |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also put this comment into the commit message, please?
{ | ||
if (cg->comp()->getOption(TR_UseSymbolValidationManager)) | ||
{ | ||
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(displacementLocation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a better commit message than "Update relocation for ClassAddress" ... I should be able to get the gist of the change just by reading the title and the text without knowing the context.
@@ -868,6 +868,7 @@ TR::X86ImmInstruction::addMetaDataForCodeAddress(uint8_t *cursor) | |||
|
|||
if (getReloKind() != -1) // TODO: need to change Body info one to use this | |||
{ | |||
TR::SymbolType symbolKind = TR::SymbolType::typeClass; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, this commit should have a stand-alone title and message.
@@ -1599,6 +1599,7 @@ TR::Node *constrainAload(OMR::ValuePropagation *vp, TR::Node *node) | |||
sym->isFinal())) | |||
haveClassLookaheadInfo = true; | |||
|
|||
bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given only classes are actually covered properly by the symbol validation manager (methods still use the "old" approach)...have you convinced yourself that the enhanced knowledge about classes doesn't end up enabling an incorrect runtime state due to the methods derived from those classes? Or will that be protected because the queries on the resulting method won't let things get out of hand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen, TR_MethodPointer
is only generated when dealing with Profiled Pointers, so it should be ok using the "old" approach due to the class chain + first class loaded from classloader validations. Additionally, TR_RamMethod
seems to be used only (or more specifically, can only be used) for the method being compiled, so that too should be ok using the "old" approach. That said, I'm doing some runs now with these changes made to the appropriate places
- if (symbolKind == TR::SymbolType::typeClass && cg()->comp()->getOption(TR_UseSymbolValidationManager))
+ if (cg()->comp()->getOption(TR_UseSymbolValidationManager))
since I can't think of any good reason why the "new" approach shouldn't working, Towards the end of this work, I did find a bug in this code that I fixed, so perhaps I won't see that crash now.
@@ -1215,8 +1215,9 @@ TR::VPClassType *TR::VPClassType::create(OMR::ValuePropagation *vp, const char * | |||
if (classObject) | |||
{ | |||
bool isClassInitialized = false; | |||
bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another commit that should have a more meaningful commit title and message
@@ -54,9 +54,8 @@ TR::X86DataSnippet::addMetaDataForCodeAddress(uint8_t *cursor) | |||
if (_isClassAddress) | |||
{ | |||
bool needRelocation = TR::Compiler->cls.classUnloadAssumptionNeedsRelocation(cg()->comp()); | |||
if (needRelocation) | |||
if (needRelocation && !cg()->comp()->compileRelocatableCode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another commit that should have a more meaningful title and message...These changes do not "Enable checkcast inlining under AOT"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needRelocation
should really be renamed to assumptionNeedsRelocation
; I'll allow it in a subsequent PR.
@@ -8058,7 +8058,9 @@ TR_ColdBlockMarker::hasNotYetRun(TR::Node *node) | |||
TR::SymbolReference *symRef = node->getSymbolReference(); | |||
bool isUnresolved; | |||
|
|||
if (comp()->compileRelocatableCode() && !comp()->getOption(TR_DisablePeekAOTResolutions)) | |||
if (comp()->compileRelocatableCode() && | |||
!comp()->getOption(TR_UseSymbolValidationManager) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you just trying to preserve the old behaviour here by overloading on TR_UseSymbolValidationManager
? The downstream code doesn't seem dependent on the symbol manager to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you just trying to preserve the old behaviour here by overloading on TR_UseSymbolValidationManager?
Yeah that's exactly it. I wanted there to be a way for the old code to run exactly as it did without all the new changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although... the isInterpretedForHeuristics
change also affects the "old" behaviour... Though, it only affects it from a heuristic point of view and, if anything, results in better decisions being made, so I suppose (like 1e645c3) is just a generally good thing to have
@@ -385,6 +385,7 @@ bool TR_ResolvedMethod::isPublic() { not | |||
bool TR_ResolvedMethod::isFinal() { notImplemented("isFinal"); return false; } | |||
bool TR_ResolvedMethod::isStrictFP() { notImplemented("isStrictFP"); return false; } | |||
bool TR_ResolvedMethod::isInterpreted() { notImplemented("isInterpreted"); return false; } | |||
bool TR_ResolvedMethod::isInterpretedForHeuristics() { notImplemented("isInterpretedForHeuristics"); return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...makes me wonder if ForHeuristics
(or its other state) is a concept worth promoting more broadly...
For example, the isUnresolved()
change you had to make in another commit...
As a general statement, it would be nicer to see these things propagate into the code base in smaller chunks and not all at once. I know Eclipse OpenJ9 is very keen to get these changes into their 0.11 release and these changes are needed to enable even bigger things in OpenJ9, but I suspect at least some of these commits could have been submitted earlier than the full batch was and could have been merged early (i.e. not all of these changes are connected to the new symbol validation manager). Anyway, it would be nice to see these improvements to the code base flowing in via a more incremental and hopefully spread out process, is my hopeful request for future submissions. |
c1e9686
to
6245869
Compare
If the user specifies higher method counts, don't delay relocation and make the scount the same as the count. Signed-off-by: Irwin D'Souza <[email protected]>
If the user specifies disableKnownObjectTable, the KNOT does not get created. However, some parts of the code assume the KNOT always exist. Signed-off-by: Irwin D'Souza <[email protected]>
6245869
to
c1b5b05
Compare
Add new external relocation types to enable the use of the Symbol Validation Manager which will be used to validate relocatable compilations. Signed-off-by: Irwin D'Souza <[email protected]>
Signed-off-by: Irwin D'Souza <[email protected]>
Enable the infrastructure to allow inlining of abstract methods inlining in relocatable compilations. Signed-off-by: Irwin D'Souza <[email protected]>
This commit adds another field into relodata so that a downstream project can make use of it. These fields are generic data fields whose contents can vary based on the relocation record being generated. Signed-off-by: Irwin D'Souza <[email protected]>
Previously, because almost everything was "unresolved" under AOT, all calls would use the unresolved dispatch. However, with the new validations, very few unresolved pointers are only unresolved because of AOT. Therefore, generating an unresolved dispatch is incorrect. The solution to this problem is to assume, during an AOT compile, that all methods are interpreted. Thus, if a method is resolved, the compiler will generate a resolved interpreter dispatch snippet, which can patch the caller if/when the method is compiled. Signed-off-by: Irwin D'Souza <[email protected]>
Sometimes, when devirtualizing, the compiler keeps the call virtual, but uses a cpIndex of -1, which causes a problem during relocation. Thus this commit adds a check to not devirtualize calls based on a Front End query. Signed-off-by: Irwin D'Souza <[email protected]>
Add a query to allow the validation of targets to be inlined for relocatable compiles. Signed-off-by: Irwin D'Souza <[email protected]>
Under the option to use the Symbol Validation Manager, the correct way to acquire the address for classes or methods, is to go through the manager, since it maintains consistency with all the validations as well as relocations. This commit transmutes the TR_ClassPointer, TR_MethodPointer, and TR_RamMethod into a TR_SymbolFromManager relocation record in order to maintain consistency with the rest of the validations. Signed-off-by: Irwin D'Souza <[email protected]>
Under the option to use the Symbol Validation Manager, the correct way to acquire the address for classes is to go through the manager, since it maintains consistency with all the validations as well as relocations. This commit transmutes the TR_ClassAddress into a TR_SymbolFromManager relocation record in order to maintain consistency with the rest of the validations. Signed-off-by: Irwin D'Souza <[email protected]>
This commit allows, under AOT and the option to use the Symbol Validation Manager, some findClassInfoAfterLocking queries in order to provide the optimizer with more information that was previously unavailable. Signed-off-by: Irwin D'Souza <[email protected]>
If a data snippet contains a class address, this address needs to be relocated. This commit ensures that the necessary relocation record is created. Signed-off-by: Irwin D'souza <[email protected]>
Under AOT, the compiler assumes some classes are unresolved, even if they actually aren't. This is because some queries will return NULL if the class can't be remembered in the SCC. Some optimizations, such as cold block marker, are affected by whether or not a block contains an unresolved reference. In AOT, many more blocks are incorrectly marked cold. This commit attempts to remedy that. Signed-off-by: Irwin D'Souza <[email protected]>
Add query for when the compiler asks about whether a method is interpreted for heuristic reasons, and not for functional correctness reasons. Signed-off-by: Irwin D'Souzai <[email protected]>
Signed-off-by: Irwin D'Souza <[email protected]>
c1b5b05
to
e0bc346
Compare
genie-omr build all |
I have opened #3029 to start documenting work that should be happen going forward to tease OpenJ9 and OMR further apart in their mutual dependency in specifically the relocation infrastructure. With that in place, I think we can merge this one now. |
This PR introduces changes in OMR required to enable optimizations that are currently implicitly disabled for relocatable compilations.
Issue tracking all the PRs: eclipse-openj9/openj9#2921